package com.lc.afbx.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/6/22.
 */
@HttpInlet(Conn.INLET_API_INSURANCE_PLATE_NUMBER)
public class GetApiConfirmXuBao extends BaseAsyGet<GetApiConfirmXuBao.Info> {
    public String type, userid;

    public GetApiConfirmXuBao(AsyCallBack<GetApiConfirmXuBao.Info> asyCallBack) {
        super(asyCallBack);
    }

    protected Info parser(JSONObject jsonObject) {

        TOAST = jsonObject.optString("message");
        if (jsonObject.optInt("code") == 200) {

            Info info = new Info();
            JSONArray array = jsonObject.optJSONArray("data");

            for (int i = 0; i < array.length(); i++) {
                Data d = new Data();
                JSONObject o = array.optJSONObject(i);

                d.id = o.optString("id");
                d.insurance_id = o.optString("insurance_id");
                d.plate_number = o.optString("plate_number");
                d.company = o.optString("company");
                d.vin = o.optString("vin");
                d.model_number = o.optString("model_number");

                info.dataList.add(d);
            }
            return info;
        }
        return null;
    }


    public static class Info {
        public List<Data> dataList = new ArrayList<>();
    }

    public static class Data {
        //        "id": "1",
//                "insurance_id": "1",
//                "plate_number": "s654566",
//                "vin": "1561616",
//                "model_number": "",
//                "company": "平安保险"
        public String id, insurance_id, plate_number, vin, company, model_number;

    }

}
